import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.StandardEvaluationContext;

import java.time.LocalDateTime;

/**
 * @author zhu_shuai
 * @since 2021/5/25
 */
public class Demo1 {
    public static void main(String[] args) {
        String temp = "hei,#message";

        ExpressionParser parser = new SpelExpressionParser();
        StandardEvaluationContext context = new StandardEvaluationContext();
        context.setVariable("message", "Hello World");
        String value = parser.parseExpression(temp).getValue(context, String.class);
        StandardEvaluationContext ctx = new StandardEvaluationContext();
        ctx.setVariable("task", "taskname");
        ctx.setVariable("nowTime", LocalDateTime.now());

        System.out.println(value);
    }
}
